#ifndef __PWM_CONTROL
#define __PWM_CONTROL

#include "config.h"

/**
 * @brief PWM 控制对象，使用 TIM1 定时器
 */
typedef struct _PWMControl PWMControl;
#define PWM_CONTROL(any) ((PWMControl *)(any))

extern PWMControl *pwm_control_new_from_global(void);

//
extern void pwm_control_connect_duty_cycle(PWMControl *self,
                                           uint16_t   *duty_cycle);

/**
 * @brief 开启 PWM 输出
 */
extern void pwm_control_start(PWMControl *self);

/**
 * @brief 设置占空比
 * @param self PWM 控制对象
 * @param duty_cycle 占空比
 */
extern void pwm_control_set_duty_cycle(PWMControl *self, uint16_t duty_cycle);

/**
 * @brief 关闭 PWM 输出
 */
extern void pwm_control_stop(PWMControl *self);

#endif
